package com.yingsheng.bi.hks.template.biz;

import com.yingsheng.bi.hks.template.events.Event;
import com.yingsheng.bi.hks.template.events.HandlerMethodEvent;
import com.yingsheng.bi.hks.template.processor.InnerProcessor;
import com.yingsheng.bi.hks.template.utils.JacksonUtils;

import java.util.HashMap;
import java.util.Map;

public class RequestDecryptProcessor extends InnerProcessor {

    @Override
    public void execInner(Event event) {
        if (event instanceof HandlerMethodEvent) {
            HandlerMethodEvent handlerMethodEvent = (HandlerMethodEvent) event;
            Map<String, Object> dataMap = new HashMap<>();
            dataMap.put("mobile", "15757871156");
            dataMap.put("acctNo", "123");
            Object before = handlerMethodEvent.getInput();
            System.out.println("解密前: " + before);
            Object after = JacksonUtils.obj2Json(dataMap);
            handlerMethodEvent.setInput(after);
            System.out.println("解密后: " + handlerMethodEvent.getInput());
            super.execInner(event);
//            handlerMethodEvent.setOutput(handlerMethodEvent.getInput());
            handlerMethodEvent.setOutput(event.getDataMap());
        } else {
            super.execInner(event);
        }
    }


    @Override
    public int getOrder() {
        return Integer.MAX_VALUE;
    }
}
